<div>
  <div class="main-title">
    <h2>未收账单</h2>
  </div>
  <div class="main-section form-inline">
    <a href="{:url('bill', ['house_property_id' => $house_property_id])}" class="btn btn-success">+ 增加</a>
    <a href="{:url('list', ['house_property_id' => $house_property_id])}" class="btn btn-success">打印</a>
    <select class="j-select form-control" style="width: 120px; margin-left: 2px;">
      <option value="{:url('', ['house_property_id' => 0])}">未选择</option>
      {foreach $properties as $v}
      <option value="{:url('', ['house_property_id' => $v.id])}" {if $house_property_id==$v.id}selected{/if}>
        {$v.name}
      </option>
      {/foreach}
    </select>
  </div>
  <div class="main-section">
    <table class="table table-striped table-bordered table-hover">
      <thead>
        <tr>
          <th>房产</th>
          <th>房号</th>
          <th>收款日期</th>
          <th>金额</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        {if $property}
        {foreach $datas as $v}
        <tr>
          <td>{$property.name}</td>
          <td>{$v.name}</td>
          <td>{$v.start_time|date='Y-m-d'}</td>
          <td>{$v.total_money}</td>
          <td>
            <a href="{:url('edit', ['id' => $v.id])}" style="margin-right: 5px;">抄表</a>
            <a href="{:url('print', ['id' => $v.id, 'number_id' => $v.house_number_id, 'house_property_id' => $house_property_id])}"
              style="margin-right: 5px;">
              打印</a>
            <a href="{:url('history', ['number_id' => $v.house_number_id, 'house_property_id' => $house_property_id])}"
              style="margin-right: 5px;">
              历史水电</a>
            <a href="{:url('account', ['id' => $v.id])}" class="j-account" style="margin-right: 5px;">到账</a>
          </td>
        </tr>
        {/foreach}
        {/if}
        {if empty($property) || $datas->isEmpty()}
        <tr>
          <td colspan="5" class="text-center">列表为空</td>
        </tr>
        {/if}
      </tbody>
    </table>
    {$datas|raw}
  </div>
</div>

<script>
  $('.j-del').click(function () {
    if (confirm('您确定要删除此项？')) {
      main.ajaxPost($(this).attr('href'), function () {
        main.contentRefresh();
      });
    }
    return false;
  });
  $('.j-account').click(function () {
    if (confirm('确定是否到账')) {
      main.ajaxPost($(this).attr('href'), function () {
        main.contentRefresh();
      });
    }
    return false;
  });
  $('.j-select').change(function () {
    main.content($(this).val());
  });
</script>